package ynu.edu.Controller;

import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;
import ynu.edu.Entity.User;

@RestController
@RequestMapping("/user")
@RefreshScope
public class UserController {

    @GetMapping("/getUserById/{userId}")
    public User getUserInfo(@PathVariable("userId") Integer userId){
        User user = new User();
        user.setUserId(userId);
        user.setUsername("张三-11112");
        return user;
    }
    @PutMapping("/updateUserName/{newUserName}")
    public User updateUserName(@PathVariable("newUserName") String newUserName){
        User user = new User();
        user.setUserId(11112);
        user.setUsername(newUserName);
        return user;
    }
    @PostMapping("/addUser")
    public User addUser(@RequestBody User user){
        user.setUserId(11112);
        user.setUsername("添加用户：张三-11112");
        return user;
    }
    @DeleteMapping("/deleteUser/{userId}")
    public User deleteUser(@PathVariable("userId") Integer userId){
        User user = new User();
        user.setUserId(userId);
        user.setUsername("删除用户：张三-11112");
        return user;
    }
}
